
package com.pinapel.aixml.models.xml.errorHandlers;

import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;

/**
 * @author Juanfran
 *
 */
public abstract class AbstractTErrorReporter implements ErrorListener {
	/** Contains if the process this reporter is handling failed **/
	private boolean mFailed;
	/** A common message (or part of it) for all showed errors **/
	private String mBaseMessage;
	
	/**
	 * Builds a new ErrorReporter
	 * @param baseMessage common part of all the messages this ErrorReporter will show.
	 */
	public AbstractTErrorReporter(String baseMessage) {
		mFailed = false;
		mBaseMessage = baseMessage;
	}
	
	/**
	 * Return if the ErrorReporter detected any error from the process it's handling.
	 * @return true if an error happened, false otherwise.
	 */
	public boolean hasError() {
		return mFailed;
	}
	
	/**
	 * Tells the ErrorReporter that an error happened in the process it's handling.
	 */
	public void setError() {
		mFailed = true;
	}
	
	/**
	 * Obtains the base message common for al the error messages that this ErrorReporter will show.
	 * @return string with the base message.
	 */
	public String getBaseMessage() {
		return mBaseMessage;
	}


	@Override
	public void warning(TransformerException arg0) throws TransformerException {
		// Ignore warnings by default.
	}


}
